/*
 * Hash.h
 *
 *  Created on: 11/10/2011
 *      Author: gisedaye
 */

#ifndef HASH_H_
#define HASH_H_
#include <string>
#include <fstream>
#include "exceptions/ExceptionNotFound.h"
#include "exceptions/ExceptionExists.h"
#include "exceptions/ExceptionFileExists.h"
#include "HashTable.h"
#include "Bucket.h"
#include "../common/Record.h"

#define MAX_BUCKETS 512
#define MAX_RECORDS 10

using namespace std;

class Hash {
private:
	HashTable * hashTable;
	string bucketsFile;
	string freeBucketsFile;
	vector<int> freeBuckets;
public:
	Hash(string filename);
	void insertValue(string id, string value);
	void modifyValue(string id, string value);
	void deleteValue(string id);
	Bucket * searchRecord(Record * record);
	void overflow(Bucket * bucket,Record * record);
	void underflow(Bucket * bucket,Record * record);
	void redisperseBuckets(Bucket * bucket,Bucket * newBucket);
	virtual ~Hash();
};

#endif /* HASH_H_ */
